Add support for MG-GPO02Z / Sparkelec SGPO2TZ#12586
Draft
KablammoNick wants to merge 4 commits into
Draft
Conversation
Add support for MG-GPO02Z / Sparkelec SGPO2TZ
Two changes made after automatic checks failed: Line 7 — removed Fz from the type import (it was unused since backlightColorToZigbee uses Tz.Converter not Fz) Line 90 — changed [...buf] to buf directly; sendDataPointRaw expects a Buffer, not a number[], so spreading it was the wrong approach
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add support for MakeGood MG-GPO02Z / Sparkelec SGPO2TZ
Original external converter was 100% vibe-coded on my end, with a bunch of additional support and testing from @bdnstn in the original thread: Koenkk/zigbee2mqtt#31952
This PR adds support for the MakeGood MG-GPO02Z dual GPO with energy monitoring and RGB backlights,
also sold in Australia under the Sparkelec SGPO2TZ brand.
The Sparkelec appears to be a slightly different/newer version (marketed as V2) but testing shows the internals are the same.
Added fingerprints
Added fingerprint:
White label added:
Device investigation
The implementation was based on datapoint information obtained from the Tuya IoT Platform device
model definitions, cross-referenced with live device behaviour reported in the linked issue.
The device uses
TS0601with the_TZE200_lq0ffndfmanufacturer name. All datapoints arecommunicated on Zigbee endpoint 1. Both sockets are mapped to endpoint 1 (i.e.
{l1: 1, l2: 1}),with socket identity carried in the DP number rather than the Zigbee endpoint.
Confirmed datapoints
switch_1switch_2countdown_1countdown_2switch_backlightadd_elecur_currentcur_powercur_voltagerelay_status_1relay_status_2child_lockbacklight_colorall_on_offAdded functionality
DP 1 / 2 — switch_1 / switch_2
Mapped to
state_l1/state_l2usingtuya.valueConverter.onOff.DP 7 / 8 — countdown_1 / countdown_2
Mapped to
countdown_l1/countdown_l2. The Tuya platform defines these asscale: 0,so values are passed as raw integers (seconds). A custom converter normalises
nullandfalseto0to avoid unexpected state values on first poll.DP 16 — switch_backlight
Mapped to
backlight_modeusingtuya.exposes.backlightModeOffOn().DP 20 — add_ele (energy)
Mapped to
energy(kWh). The Tuya platform defines this asscale: 3, so the raw integeris divided by 1000. The device reports incremental energy values rather than a running total;
a custom accumulating converter adds each reported delta to the previous state value and
ignores zero or negative jumps to prevent spurious resets.
DP 21 — cur_current
Mapped to
current(A) usingtuya.valueConverter.divideBy1000. Tuya reports in mA withscale: 0.DP 22 — cur_power
Mapped to
power(W) usingtuya.valueConverter.divideBy10. Tuya reports withscale: 1.DP 23 — cur_voltage
Mapped to
voltage(V) usingtuya.valueConverter.divideBy10. Tuya reports withscale: 1.DP 29 / 30 — relay_status_1 / relay_status_2
Mapped to
power_on_behavior_l1/power_on_behavior_l2using a lookup converter withTuya enum values
0 = power_off,1 = power_on,2 = last.DP 101 — child_lock
Mapped to
child_lockusing a boolean lookup (LOCK/UNLOCK).DP 107 — backlight_color
The Tuya platform exposes a 21-byte raw payload encoding per-socket LED color for both on and
off states. The structure is:
Hue is 0–360, saturation is 0–1000, brightness is 0–100. A custom
toZigbeeconverter(
backlightColorToZigbee) serialises a JSON object into this buffer and sends it viatuya.sendDataPointRaw. The converter is only meaningful whenbacklight_modeisON;this is noted in the expose description.
DP 136 — all_on_off
Mapped to
all_on_offusingtuya.valueConverter.onOff. Listed inmultiEndpointSkipso it is not duplicated per endpoint.
Notes
breakdown. These are listed in
multiEndpointSkipaccordingly.endpoint 1. The
endpointfunction returns{l1: 1, l2: 1}.new
MG-GPO02Zdefinition tomakegood.ts.brands in the Australian market.
Link to Sparkelec product page: https://agmelectrical.com.au/home-automation-wifi-intercoms-smart-switches-and-power-points/sparkelec-touch-zigbee-wifi-switches-and-power-points/double-power-point-10a-smart-zigbee-touch-glass-wall-switch-off-white-sparkelec-sgpo2tz-white.html
Link to picture pull request: Koenkk/zigbee2mqtt.io#5290